package com.zhibang.report.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sannuo.common.domain.Jcjl;
import com.sannuo.common.domain.bo.Cs;
import com.sannuo.common.domain.bo.Jccx;
import com.sannuo.common.result.Result;
import com.sannuo.common.result.ResultCode;

import com.zhibang.report.service.JcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/Jc")
public class JcController {
    @Autowired
    private JcService jcService;

    @RequestMapping(value = "jc",method = RequestMethod.GET)
    public Result jc(String searchParams,Integer page,Integer limit)throws Exception{
        Jccx jccx=null;
        if(searchParams!=null){
            jccx=new ObjectMapper().readValue(searchParams,Jccx.class);
        }
        Page page1 = PageHelper.startPage(page, limit);
        List<Jcjl> jcjls = jcService.selectJcjl(jccx);
        System.out.println(page1);
        return Result.ok(ResultCode.SUCCESS,page1.getTotal(),jcjls);
    }

}
